:root {
  --font-main: "Segoe UI", Arial, sans-serif;
  --bg: #f4f6fa;
  --panel: #ffffff;
  --sidebar: #2f3e52;
  --text: #263241;
  --muted: #6f7c8c;
  --line: #e0e6ef;
  --accent: #f5a000;
  --ok: #2e9f62;
  --warn: #d7a11e;
  --bad: #d14a4a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--bg);
  color: var(--text);
}
button, input, select, textarea { font-family: var(--font-main); }

.app-shell { display: flex; min-height: 100vh; }
.app-shell.login-only .sidebar { display: none; }
.app-shell.login-only .topbar { display: none; }
.app-shell.login-only .main { padding: 0; width: 100%; }
.app-shell.login-only .panel { margin-top: 0; }
.sidebar {
  width: 250px;
  background: var(--sidebar);
  color: #fff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0;
}
.brand-text { font-size: 28px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  text-align: left; border: 0; border-radius: 8px; padding: 10px 12px;
  background: transparent; color: #d2d9e3; cursor: pointer; display: flex; align-items: center; gap: 10px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.12s ease;
}
.menu-item:hover, .menu-item.active {
  background: #43546d;
  color: #fff;
}
.menu-item:hover { transform: translateX(1px); }
.menu-icon-svg {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.05);
}
.menu-icon-svg svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.95;
}
.menu-item.active .menu-icon-svg {
  border-color: rgba(245, 160, 0, 0.55);
  background: rgba(245, 160, 0, 0.12);
  box-shadow: 0 0 0 1px rgba(245, 160, 0, 0.2);
}
.sidebar-footer { margin-top: auto; }

.main { flex: 1; padding: 18px 22px; }
.topbar {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-title-wrap { display: flex; align-items: center; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
#productionHeaderFilters {
  margin-bottom: 0;
  align-items: center;
  gap: 10px;
}
h1 { margin: 0; font-size: 24px; text-align: left; }
.user-badge { background: #f0f3f8; border-radius: 999px; padding: 8px 12px; font-size: 13px; }

.panel {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px;
}
.login-panel {
  position: relative;
  overflow: hidden;
  min-height: 340px;
  background: #eef3f8;
  color: #1f2b39;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding-bottom: 20px;
}
.app-shell.login-only .login-panel {
  border: 0;
  border-radius: 0;
  min-height: 100vh;
}
.login-hero {
  width: calc(100% + 32px);
  margin: -16px -16px 0 -16px;
  height: 190px;
  background:
    url("/ui-asset/login-hero")
    center / contain no-repeat;
  background-color: #dfe6ee;
}
.app-shell.login-only .login-hero {
  width: 100%;
  margin: 0;
  height: 260px;
  background-size: cover;
}
.login-center {
  width: min(680px, 100%);
  margin: 16px auto 0 auto;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(190, 200, 214, 0.7);
  border-radius: 14px;
  padding: 22px 24px;
  backdrop-filter: blur(3px);
}
.app-shell.login-only .login-center {
  margin-top: 28px;
}
.login-logo {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  margin: 0 auto 8px auto;
}
.login-center h2 {
  text-align: center;
  margin: 0 0 12px 0;
  color: #213042;
}
.login-center label {
  color: #4e6076;
}
.login-center input {
  background: #fff;
}
.login-btn {
  min-width: 180px;
  margin: 6px auto 4px auto;
  display: block;
}
.hidden { display: none; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .push-right { margin-left: auto; }
.planning-legacy-toolbar { display: none; }
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.admin-tab-btn {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  font-weight: 600;
}
.admin-tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.admin-tab-content h3 {
  margin-top: 0;
}
#permissionsTable .perm-check {
  width: 14px;
  height: 14px;
  min-width: 14px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #c9d3e0;
  border-radius: 2px;
  background: #fff;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}
#permissionsTable .perm-check::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
  transition: transform 0.12s ease-in-out;
}
#permissionsTable .perm-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}
#permissionsTable .perm-check:checked::after {
  transform: rotate(-45deg) scale(1);
}
#permissionsTable .perm-cell {
  text-align: center;
}
.wide-note input { min-width: 280px; }
.compact-check { gap: 4px; min-width: 120px; }
.inline-right {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.compact-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #c9d3e0;
  border-radius: 3px;
  background: #fff;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
}
.compact-check input[type="checkbox"]::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
  transition: transform 0.12s ease-in-out;
}
.compact-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.compact-check input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) scale(1);
}
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  min-width: 140px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px;
  background: #fff;
}
input.invalid-field,
select.invalid-field {
  border: 2px solid #d14a4a !important;
  background: #fff3f3 !important;
}
.primary-btn, .ghost-btn {
  height: 36px; border: 0; border-radius: 8px; padding: 0 14px; cursor: pointer;
}
.primary-btn { background: var(--accent); color: #fff; font-weight: 600; }
.ghost-btn { background: #43546d; color: #fff; }
.danger-btn,
#modalAbortBtn {
  background: #c93b3b !important;
  color: #fff !important;
}
#modalAbortBtn:hover,
.danger-btn:hover {
  background: #ad2f2f !important;
}
.success-btn {
  background: var(--ok) !important;
  color: #fff !important;
}
.success-btn:hover {
  background: #238653 !important;
}
#backlogPlanSaveBtn {
  background: var(--ok) !important;
  color: #fff !important;
}
#backlogPlanSaveBtn:hover {
  background: #238653 !important;
}
#modalSetDefinitiveBtn {
  background: var(--ok) !important;
  color: #fff !important;
}
#modalSetDefinitiveBtn:hover {
  background: #238653 !important;
}
.shift-toggle { margin-left: 4px; align-self: center; }
.notifications-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px 12px;
  margin-top: 8px;
}
.notification-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.notification-item:last-child { border-bottom: 0; }
.notification-meta { color: var(--muted); font-size: 12px; }

.sales-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.sales-user-tools {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
}
.sales-user-tools span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sales-user-tools i {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ecf1f8;
  border: 1px solid #d4dce8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 11px;
  color: #516177;
}
.sales-user-tools .tool-icon svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sales-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.sales-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.kpi-card {
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.kpi-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.kpi-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.kpi-value { font-size: 34px; font-weight: 700; line-height: 1; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }
.kpi-ring {
  --val: 50;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: conic-gradient(var(--accent) calc(var(--val) * 1%), #e7edf5 0);
  display: grid;
  place-items: center;
}
.kpi-ring span {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.kpi-progress {
  height: 10px;
  border-radius: 999px;
  background: #e8edf4;
  overflow: hidden;
}
.kpi-progress > div {
  height: 100%;
  background: linear-gradient(90deg, var(--ok), #78c96f);
}
.sales-visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.sales-visual-card h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}
.sales-bars {
  display: grid;
  gap: 8px;
}
.sales-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 52px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.sales-bar-track {
  background: #e9eef6;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
}
.sales-bar-fill {
  height: 10px;
  background: linear-gradient(90deg, #5f8cc6, #2f6fbd);
  border-radius: 999px;
}
.sales-details {
  margin-top: 12px;
}
.sales-details summary {
  cursor: pointer;
  color: var(--muted);
  margin-bottom: 8px;
}
.card {
  background: #fafbfd; border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.card .title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card .value { font-size: 24px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
th { background: #f8fafc; color: #5f6c7c; font-weight: 600; }
th { text-transform: uppercase; letter-spacing: 0.02em; }
tr.is-selected td { background: #fff4df; }
tr.is-aborted:not(.is-selected) td { background: #fdeaea; color: #9f2a2a; }

.badge {
  display: inline-block; min-width: 72px; text-align: center;
  padding: 4px 8px; border-radius: 999px; color: #fff; font-size: 12px;
}
.badge.green { background: var(--ok); }
.badge.yellow { background: var(--warn); color: #263241; }
.badge.red { background: var(--bad); }

.grid-two { display: grid; grid-template-columns: repeat(2, minmax(180px, 1fr)); gap: 12px; margin-bottom: 10px; }
.grid-three { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; margin-bottom: 10px; }
.inline-check { margin: 8px 0 12px; color: var(--text); }
.muted { color: var(--muted); font-size: 13px; }
.error-message {
  color: #c93b3b !important;
  font-weight: 600;
}
.avor-layout {
  display: grid;
  grid-template-columns: minmax(420px, 520px) minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}
.card-like {
  background: #fafbfd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}
.avor-layout h3 {
  margin: 0 0 8px 0;
  font-size: 16px;
}
.avor-backlog .table-wrap,
.avor-machine-overview .timeline-grid {
  margin-bottom: 0;
}
.avor-backlog .table-wrap {
  margin-top: 8px;
}
.avor-backlog table {
  font-size: 13px;
}
.avor-backlog th,
.avor-backlog td {
  white-space: normal;
  vertical-align: top;
}
.avor-backlog th:last-child,
.avor-backlog td:last-child {
  min-width: 130px;
}

.timeline-grid {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  margin-bottom: 14px;
  position: relative;
  font-size: 13px;
}
.timeline-slider-wrap {
  margin-top: 2px;
  margin-bottom: 6px;
  padding-left: 240px;
  position: relative;
  z-index: 1;
}
.timeline-slider-wrap input[type="range"] {
  width: calc(100% - 4px);
  min-width: 0;
  height: 12px;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
}
.timeline-slider-wrap input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  background: rgba(95, 108, 124, 0.4);
  border-radius: 999px;
}
.timeline-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: #43546d;
  cursor: pointer;
}
.timeline-slider-wrap input[type="range"]::-moz-range-track {
  height: 3px;
  background: rgba(95, 108, 124, 0.4);
  border-radius: 999px;
}
.timeline-slider-wrap input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #fff;
  background: #43546d;
  cursor: pointer;
}
.timeline-header, .timeline-row {
  display: grid;
  min-width: 2140px;
}
.timeline-header div, .timeline-row div {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #eff2f7;
  font-family: var(--font-main);
  font-size: 13px !important;
  line-height: 1.2;
}
.timeline-header div {
  min-height: 26px;
  background: #f8fafc;
  color: #3f4d60;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  padding: 4px 2px;
}
.timeline-header .timeline-label {
  color: #5f6c7c;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: left;
  padding: 4px 8px;
}
.timeline-row div {
  min-height: 52px;
}
.timeline-label {
  position: sticky;
  left: 0;
  background: #f9fbfe;
  z-index: 2;
  padding: 4px 8px;
  font-weight: 600;
  font-family: var(--font-main);
  font-size: 13px !important;
  line-height: 1.2;
  color: #5f6c7c;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.timeline-lane {
  position: relative;
  grid-column: 2 / span 96;
  min-height: 52px;
  border-right: 1px solid var(--line);
  overflow: hidden;
}
.timeline-now-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #d92525;
  z-index: 8;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.timeline-center-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: #d92525;
  z-index: 12;
  pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.timeline-center-time {
  position: absolute;
  top: -18px;
  left: 0;
  transform: translateX(-50%);
  z-index: 13;
  background: #d92525;
  color: #fff;
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  pointer-events: none;
}
.timeline-overlay {
  position: sticky;
  top: 26px;
  bottom: 0;
  left: 240px;
  right: 0;
  z-index: 11;
  overflow: hidden;
  pointer-events: none;
}
.timeline-block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  min-height: 0;
  border-radius: 4px;
  padding: 3px 8px 3px 5px;
  font-family: var(--font-main);
  font-size: 13px;
  color: #fff;
  background: #2f6fbd;
  cursor: grab;
  overflow: hidden;
  white-space: normal;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: none;
}
.timeline-block-line1,
.timeline-block-line2 {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.timeline-block-line1 {
  font-weight: 700;
  font-size: 13px;
}
.timeline-block-line2 {
  opacity: 0.95;
  font-size: 13px;
}
.timeline-block.confirmed {
  background: var(--ok);
}
.timeline-block.provisional {
  background: var(--accent);
  opacity: 0.5;
}
.timeline-resize {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: ew-resize;
  background: rgba(255, 255, 255, 0.6);
}

@media (max-width: 1220px) {
  .avor-layout {
    grid-template-columns: 1fr;
  }
  .sales-kpis {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
  .sales-visual-grid {
    grid-template-columns: 1fr;
  }
  .sales-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(22, 35, 52, 0.42);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden {
  display: none;
}
.modal-card {
  width: min(760px, 96vw);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 26px rgba(24, 38, 58, 0.22);
}
.modal-card h3 {
  margin: 0 0 10px 0;
}
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.plan-status-badge {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.plan-status-green { background: var(--ok); }
.plan-status-orange { background: var(--accent); }
.plan-status-red { background: #c93b3b; }
